import { Nodes } from '@knno/dom';
import { Group as UIGroup } from '../components/group/group';
import { JSXProps } from '@knno/dom/jsx';
import { AttrCheck, isArray, isStr, jsxBuild } from './utils';

export { UIGroup };

interface GroupProps extends JSXProps<UIGroup> {
	name?: string;
	value?: string[];
	text?: string;
}

const ATTRS: AttrCheck = {
	name: isStr,
	value: isArray,
	text: isStr,
};

export function Group(props: GroupProps, children: Nodes[]): UIGroup {
	return jsxBuild(new UIGroup(), props, children, ATTRS);
}
